<template>
  <div id='subtemp'>
      <div @click='substrict()' class="left div">-</div>
      <div class='center div' v-text="count"></div>
      <div @click="add()" class='right div'>+</div>
  </div>
</template>
<script>
export default {
    props:['carcount'],
  data () {
    return {
        count:1,
    };
  },
  methods:{
      substrict(){
          this.count--;
          if(this.count<1){
              this.count=1;
          }
          this.send();
      },
      add(){
          this.count++;
          this.send();
      },
      send(){
          this.$emit("sendata",this.count);
      }

  }
}
</script>
<style lang="css" scoped>
    #subtemp .div{
        border:1px solid rgba(0,0,0,.6);
        display: inline-block;
        width: 40px;
        height: 24px;
        line-height: 20px; 
        text-align: center;
    }
</style>